<?php

namespace App\Models;

use App\Models\base\FengtModel;
use App\Models\base\WarehouseModel;
use App\Models\dispatch\CarModel;
use App\Models\dispatch\DriverModel;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Model as BaseModel;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;

class DispatchTaskDriverModel extends BaseModel
{
    use HasFactory, SoftDeletes;

    protected $table = 't_dispatch_task_driver';

    protected $primaryKey = 'id';

    public $timestamps = true;

    const CREATED_AT = 'created_at';
    
    const UPDATED_AT = null;

    protected $guarded = [];

    protected $hidden = [
        'deleted_at',
    ];

    //状态 1待运输 2运输中 3已完成
    const STATUS_WAIT = 1;
    const STATUS_TRANSPORTING = 2;
    const STATUS_FINISHED = 3;
    const STATUS_MAPS = [
        self::STATUS_WAIT => '待运输',
        self::STATUS_TRANSPORTING => '运输中',
        self::STATUS_FINISHED => '已完成'
    ];

    const DRIVER_STATUS = [
        1 => [
            1 => '出发',
            2 => '到仓',
            3 => '装货完成，出发封关',
            4 => '到达封关场',
            5 => '封关离场',
            6 => '到达口岸，转交香港司机'
        ],
        2 => [
            1 => '口岸接车',
            2 => '过关',
            3 => '卸货',
        ],
        3 => [
            1 => '出发',
            2 => '到仓',
            3 => '装货完成，出发封关',
            4 => '到达封关场',
            5 => '封关离场',
            6 => '过关',
            7 => '卸货',
        ]
    ];





    //任务
    public function task(): BelongsTo {
        return $this->belongsTo(DispatchTaskModel::class, 'task_id');
    }
}
